'use strict';

const Controller = require('egg').Controller;

class IndexController extends Controller {
    /**
     * 前端展示入口
     * 
     * @memberof IndexController
     */
    async index() {
        let { ctx, service } = this;
        let user = ctx.session.user
        if (user) {
            let result = await service.index.project(user.user_id)
            await ctx.render('home/homeIndex', {
                result,
                user
            })
        } else {
            ctx.redirect('/')
        }
    }
    /**
     * 
     * 后端添加项目入口
     * @memberof IndexController
     */
    async admin() {
        let { ctx, service } = this;
        let user = ctx.session.user
        if (user) {
            let result = await service.index.project(user.user_id)
            await ctx.render('admin/admin', {
                result,
                user
            })
        } else {
            ctx.redirect('/')
        }


    }
}

module.exports = IndexController;